// permission.js
export default {
  methods: {
    getPermissions(moduleId = null) {
      try {
        const authList = this.$store.state.authorityList
        const id = moduleId ? moduleId : this.$route.meta.moduleId
        const permission = authList.find(item => item.moduleId == id)

        return {
          permission:permission,
          showRoleAdd: permission.opeAdd || 0,
          showRoleCheck: permission.opeCheck || 0,
          showRoleEdit: permission.opeEdit || 0,
          showRoleDel: permission.opeDel || 0
        }
      } catch (error) {
        console.error('获取权限出错:', error)
        return {
          showRoleAdd: 0,
          showRoleCheck: 0,
          showRoleEdit: 0,
          showRoleDel: 0
        }
      }
    }
  }
}